//
//  Brand_ExploreAttention_Cell_WX.m
//  ZITHER
//
//  Created by weixin on 2019/5/20.
//  Copyright © 2019 weixn. All rights reserved.
//

#import "Brand_ExploreAttention_Cell_WX.h"

@implementation Brand_ExploreAttention_Cell_WX

- (void)awakeFromNib {
    [super awakeFromNib];
    [self setMasmay];
}

-(void)setMasmay{
    [self addSubview:self.TopTitle];
    
    [self.TopTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.equalTo(self).offset(0);
        make.height.mas_equalTo(0);
        make.bottom.equalTo(self).offset(-70);
    }];
    
    CGFloat w = (kScreenW-20-30)/3.0;
    for (int i =0; i<3; i++) {
        BaseBtn * btn = [BaseBtn initCustomBtnTitlestype:@[@"标签"] color:@[[UIColor baseColor]]];
        [btn setCornerRadiusWithRadius:4 isMasks:YES];
        [btn setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:@"探索_兴趣背景%d",i+1]] forState:UIControlStateNormal];
        btn.tag = i+100;
        [self addSubview:btn];
        btn.hidden = YES;
        [btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.TopTitle.mas_bottom).offset(0);
            make.left.equalTo(self).offset(15+(w+10)*i);
            make.height.mas_equalTo(60);
            make.width.mas_equalTo(w);
        }];
        
        [[btn addTag]subscribeNext:^(id  _Nullable x) {
            NSInteger index = 0;
            
            if (self.HLMode.data.count==0) {
                index = 0;
            }else{
                index =self.indexPath.row-1;
            }
            NSInteger dataCount = (index)*3;

            createHotLabelModelSub *model =  self.HLMode.data[dataCount+btn.tag-100];
//btn
        }];
        [self.BtnArr addObject: btn];
    }
    
}

- (Brand_ExploreTitle_View_WX *)TopTitle{
    if (!_TopTitle) {
        _TopTitle = [[Brand_ExploreTitle_View_WX alloc]init];
        _TopTitle.title.text = @"兴趣";
    }
    return _TopTitle;
}

-(void)setHLMode:(createHotLabelModel *)HLMode{
    _HLMode = HLMode;
    NSInteger index = 0;
    
    if (self.HLMode.data.count==0) {
        index = 0;
    }else{
        index =self.indexPath.row-1;
    }
    
    NSInteger dataCount = (index)*3;

    //一共取几条
    NSInteger Count = 0;
    
    if (dataCount+2-self.HLMode.data.count>0) {
        Count = 3;
    }else{
        Count = self.HLMode.data.count-dataCount;
    }
    
    NSLog(@"%@, %ld , %ld",self.indexPath,dataCount,Count);
    for (int i = 0; i<Count; i++) {
     createHotLabelModelSub *model =  HLMode.data[dataCount+i];
        BaseBtn * btn = self.BtnArr[i];
        btn.hidden = NO;
        [btn setTitle:model.labelName forState:UIControlStateNormal];
    }
    
    
}

-(NSMutableArray *)BtnArr{
    if (!_BtnArr) {
        _BtnArr = [[NSMutableArray alloc]init];
    }
    return _BtnArr;
}


@end
